from wxauto import WeChat
import json

wx = WeChat()

listen_list = []

# 保存好友列表
file_path = r"C:\Users\Administrator\Desktop\wc\deep-seek-wechat\fri.txt"

def list_friends():
    try:
        friend_details = wx.GetFriendDetails(10,100)
        with open(file_path, 'w', encoding='utf-8') as file:
            for f in friend_details:
                f1 = json.dumps(f,ensure_ascii=False)
                file.write(f1 + "\n")
                print(f1)
        print(friend_details)
    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    list_friends()